//
//  Inventory.h
//  A One POS
//
//  Created by AonePOS on 24/09/13.
//  Copyright (c) 2013 AonePOS. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "pagination.h"
#import "jobpagination.h"
#import "Vendorpagination.h"
#import "Productpagination.h"
#import "ProductCell.h"
#import "CategoryCell.h"
#import "DepartmentCell.h"
#import "VendorCell.h"
#import "InventorySalesCell.h"
#import "OrderingInfoCell.h"
#import "ModifierItemCell.h"

@interface Inventory : UIViewController<UITextFieldDelegate,UITextViewDelegate,UITableViewDataSource,UITableViewDelegate,UIAlertViewDelegate,NSURLConnectionDataDelegate>
{
    
    UIView *sidemenu,*mainview,*backgroundcolorview;
    UIButton *categorybutton;
    UIToolbar *downtoolBar,*maintoolBar;
    UIImageView *logobackview,*logoimageview;
    int y,p;
    _Bool isLandScope;
    UIButton *helpiconButton,*logouticonButton,*menubutton;
    BOOL menuslected;
    UIButton *ProductBtn,*CategoryBtn,*DepartmentsBtn,*VendorsBtn;
    UINavigationBar *navBar;
//category view
    UIView *addCategoryBackView;
  UIScrollView  *addCategoryView;
    UITableView *editCategoryTable;
    // add category view
    UITextField *categoryidField;
    UILabel *catIDlbl,*catdesLbl;
    UITextView *catDesField;
    UIButton *saveCategoryBtn,*cancelcatBtn,*addcategoryBtn,*EditCategoryBtn;
    UIButton *editBtn,*deleteBtn;
    NSInteger selectedcat;
    UIAlertView *deletecategoryAlert;
    NSMutableArray *updateTableArray,*updateTableArray2;
    NSMutableArray *categoryIdsArray,*categorynamesArray,*categoryDesArray;
    //category edit view
    UIView *editCatpopupview,*EditCategoryView;
    UITextField *ChangecategoryidField;
    UILabel *ChnagecatIDlbl,*ChangecatdesLbl;
    UITextView *ChengecatDesField;
    UIButton *ChangesaveCategoryBtn,*ChangecancelcatBtn,*ChangeaddcategoryBtn,*ChangeEditCategoryBtn;
    NSString *nameCat,*CatDes;
//Department view
    UIView *depertmentView;
    //add deparment
    UIScrollView *addDepartmentView;
    UIButton *addDeptbtn,*Editdeptbtn;
    UIButton *CatforthisDeptBtn;
    UITextField *IDfield;
    UILabel *deptIDlbl,*deptdesLbl,*deptcatidlbl;
    UITextView *deptDestextView;
    UIButton *savedeptBtn,*canceldeptbtn;
    UITableView *EditDeptTable;
    UITableView *categorysListTable,*PrinterslistTable;
    NSMutableArray *departmentIDsArray,*DepartmentNamesArray,*DepartmentDesArray,*DeptCatIdsArray,*deptprintersArray,*deptfoodsArray,*depttaxesArray;
    UIButton *dataEditBtn,*dataDeleteBtn,*DuplicateBtn;
    UIButton *Deptax1Btn,*Deptax2Btn,*Deptax3Btn,*DepBarTaxBtn,*DeptfoodstampleBtn,*DeptprinterBtn;
    UILabel *Deptax1lbl,*Deptax2lbl,*Deptax3lbl,*Depbartaxlbl,*DeptFoodstampablelbl,*Deptprinterlbl;
     UIAlertView *deleteDeptAlert;
    NSString *DepTaxValueStr,*Deptfoodstampable;
    NSMutableArray *PrinterslistArray;
    NSMutableArray *MinitsArray;
    UILabel *TimeForDeptlbl;
    UIButton *MinitBtn,*SecsBtn;
    UITableView *MinitslistTable,*SecslistTable;
    
    NSMutableArray *TimesArray;
    
    //edit department
    UIScrollView *EditDepartmentView;
    UIView *editDepartmentpopup;
    UIButton *ChangeaddDeptbtn,*ChangeEditdeptbtn;
    UIButton *ChangeCatforthisDeptBtn;
    UITextField *ChangeIDfield;
     UITableView *ChangecategorysListTable,*ChangePrinterslistTable;
    UILabel *ChangedeptIDlbl,*ChangedeptdesLbl,*Changedeptcatidlbl;
    UITextView *ChangedeptDestextView;
    UIButton *ChangesavedeptBtn,*Changecanceldeptbtn;
    NSString *nameDept,*idDept,*desDept;
    UIButton *ChangedataEditBtn,*ChangedataDeleteBtn,*ChangeDuplicateBtn;
    UIButton *ChangeDeptax1Btn,*ChangeDeptax2Btn,*ChangeDeptax3Btn,*ChangeDepBarTaxBtn,*ChangeDeptfoodstampleBtn,*ChangeDeptprinterBtn;
    UILabel *ChangeDeptax1lbl,*ChangeDeptax2lbl,*ChangeDeptax3lbl,*ChangeDepbartaxlbl,*ChangeDeptFoodstampablelbl,*ChangeDeptprinterlbl;
    NSString *EditDeptfoodstampable;
    
    UILabel *ChangeTimeForDeptlbl;
    UIButton *ChangeMinitBtn,*ChangeSecsBtn;
    UITableView *ChangeMinitslistTable,*ChangeSecslistTable;
    
    
    //Duplicate department view
    UIView *DuplicateDepartmentpopup;
     UIScrollView *DuplicateDepartmentView;
    UIButton *DuplicateCatforthisDeptBtn;
    UITextField *DuplicateIDfield;
    UILabel *DuplicatedeptIDlbl,*DuplicatedeptdesLbl,*Duplicatedeptcatidlbl;
    UITextView *DuplicatedeptDestextView;
    UIButton *DuplicatesavedeptBtn,*Duplicatecanceldeptbtn;
    UITableView *DuplicateEditDeptTable;
    UITableView *DuplicatecategorysListTable;
    UIButton *DuplicateDeptax1Btn,*DuplicateDeptax2Btn,*DuplicateDeptax3Btn,*DuplicateDepBarTaxBtn,*DuplicateDeptfoodstampleBtn,*DuplicateDeptprinterBtn;
    UILabel *DuplicateDeptax1lbl,*DuplicateDeptax2lbl,*DuplicateDeptax3lbl,*DuplicateDepbartaxlbl,*DuplicateDeptFoodstampablelbl,*DuplicateDeptprinterlbl;
    UITableView *DuplicatePrinterslistTable;
    
    UILabel *DuplicateTimeForDeptlbl;
    UIButton *DuplicateMinitBtn,*DuplicateSecsBtn;
    UITableView *DuplicateMinitslistTable,*DuplicateSecslistTable;
    
//vendors view
    UIView *vendorsView;
    UIScrollView *AddvendorsView;
    
    UIButton *AddvendorBtn,*EditvendorBtn;
    UILabel *generalinfolbl,*Addresslbl;
    UITextField *GeneralinfoField,*AddressField;
    UILabel *InfotextLbl,*AddresstextLbl;
    UIButton *DeliverymethodBtn;
    UITableView *DeliveryTypesTable;
    UIButton *SaveVendorsBtn,*CancelVendorBtn;
    UITableView *EditVendorTable;
    NSArray *DeliverymethodsArray;
    UILabel *polbl;
    NSString *vendorNO,*Terms,*minimumOrder,*commission,*Companyname,*FlatRent,*TaxtID,*Billable,*Socialsecurity,*streetAddress,*ExtendedAddress,*City,*state,*Zipcode,*country,*firstname,*lastname,*phNUmber,*faxnumber,*email,*website;
    //edit vvendor view
    UIButton  *Editvendor,*DeleteVendor;
    NSMutableArray *VendornumbersArray,*termsArray,*minimumorderArray,*commissionsArray,*companyNAmesArray,*flatrentsArray,*TaxidsArray,*billablesArray,*socialsArray,*podeliverysArray,*streetaddressArray,*exteddedArray,*streetsArray,*citysArray,*statesArray,*ZipcodesArray,*countrysArray,*firstnamesArray,*lastnamesArray,*phnumbersArray,*faxesArray,*emailsArray,*websitesArray;
    UIAlertView *deletevendorAlert;
    NSInteger selectedVendor;
    UIView *EditVendorPopup;
    UIScrollView *EditvendorScrollView;
    UILabel *changepolbl;
    UILabel *chnagegeneralinfolbl,*changeAddresslbl;
    UITextField *chnageGeneralinfoField,*chnageAddressField;
    UILabel *chnageInfotextLbl,*chnageAddresstextLbl;
    UIButton *changeDeliverymethodBtn;
    UITableView *changeDeliveryTypesTable;
    UIButton *changeSaveVendorsBtn,*changeCancelVendorBtn;
    NSString *ChangevendorNO,*ChangeTerms,*ChangeminimumOrder,*Changecommission,*ChangeCompanyname,*ChangeFlatRent,*ChangeTaxtID,*ChangeBillable,*ChangeSocialsecurity,*ChangestreetAddress,*ChangeExtendedAddress,*ChangeCity,*Changestate,*ChangeZipcode,*Changecountry,*Changefirstname,*Changelastname,*ChangephNUmber,*Changefaxnumber,*Changeemail,*Changewebsite;
    
//product view
    
    UIView *ProductView;
    //add product view
    UIScrollView *AddProductScrollView;
    UIButton *AddProductBtn,*EditProductBtn;
    UIButton *DepartmentBtn,*SaveProductBtn,*CancelProductBtn,*tax1Btn,*tax2Btn,*tax3Btn,*BarTaxBtn,*PriceWithTaxBtn,*AddpricingBtn;
    UITextView *DescriptionText;
    UITextField *ItemNumberField,*ItemNameField,*CostField,*PriceyouChargeField,*InStockField;
    UILabel *Departmentlbl,*ItemNumberlbl,*ItemNamelbl,*Descroptionlbl,*datalbl,*pricinglbl,*tax1lbl,*tax2lbl,*tax3lbl,*bartaxlbl,*Costlbl,*priceyouChargelbl,*priceWithTaxlbl,*InStocklbl,*Addpricinglbl;
     UITableView *DepartmentsTable,*VendorsTable;
    NSString *Tax;
 
   //optionalinfo view
       UIView *OptionalInfoView,*OptionalInfoBackView;
    UITextField *OptionalinfoFields;
    UIButton *optCommissionBtn,*ItemBtn,*OptionalinfoSaveBtn,*OptionalinfoCancelBtn,*AddskuBtn;
    UILabel *Optionalinfolbl,*OptCommissonlbl,*Alternatelbl,*tagAlongitemlbl,*Itemlbl,*OptionalinfoTextLbl;
    UITableView *AlternateTable,*TagAlongitemtable,*CommissionsTable;
    NSString *modifierItem,*CountthisItem,*allowbuyback,*printonreceipt,*foodstampable,*Promptprice;
    NSMutableArray *modifierItemsArray,*CountthisitemsArray,*allowbuybackArray,*printonreciptArray,*foodstampableArray,*promptpricesArray,*OptCommissionsArray,*OpBonuspointsArray,*OpBarcodesArray,*OplocationsArray,*OpunisizesArray,*OpunittypesArray,*OpcommisArray;
    NSString *OPBonusPoints,*OPBarcodes,*OPunittype,*OPunitsize,*OPlocation,*OPCommission;
     //edit optional info view
       NSString *EditmodifierItem,*EditCountthisItem,*Editallowbuyback,*Editprintonreceipt,*Editfoodstampable,*Editpromptprice;
    NSString *modifierItemStr,*countthisitemStr,*allowbuybackStr,*printonReceiptStr,*foodstampableStr,*PromptpriceStr;
    NSString *Editbonuspoint,*Editbarcode,*Editlocation,*Editunitsize,*EditUnittype,*Editcommission;
    
    //add sku's view
    NSMutableArray *allSkusArray,*SelectedSkusArray;
    UIView *AddskupopupView,*addskuView;
    UILabel *skuTextlbl;
    UITextField *SkuField;
    UIButton *saveSkuBtn,*CancelSkuBtn,*DeleteSkuBtn;
    NSMutableArray *SkusArray;NSString *SkuStr;
    
    
    //Pending Orders
    UIView *PendingOrderBackView,*PendingOrderView;
    UILabel *openlbl,*completelbl,*cancellbl,*PendingOrderTextlbl;
    UIButton *OpenRadioBtn,*CompleteRadioBtn,*CancelRadioBtn,*CompletethisorderBtn,*cancelthisOrderBtn,*SavePendingorderBtn,*CancelPendingorderBtn;
    UITableView *PendingOrdersTable;
   //Notes View
    UIView *NotesBackView,*NotesView;
    UITextView *NotesTextView;
    UILabel *Notestextlbl;
    UIButton *SaveNotesBtn,*CancelNotesBtn;
    NSString *Productnotes;NSMutableArray *productNotesArray;
    
       //edit Notes view
    NSString *EditProductNotes,*productnotesStr;
    NSString *DuplicateproductNotes;
    
    
    
    //Future Change of modifier View

   //Modifier View
   UIView *ModifierBackView,*ModifierView,*ModifierGroupView;
    UIButton *GroupRadioBtn,*IndividualRadioBtn,*SaveGroupModifierBtn,*CancelGroupModifierBtn,*ChargeforModifierBtn,*ForceBtn,*ToSelectBtn,*AddModifierGroupBtn,*AddModifierBtn,*SaveIndividualBtn,*CancelIndividualBtn;
  UILabel *Grouplbl,*individuallbl,*Toselectlbl,*ModifierDeslbl,*promptlbl,*chargeforModifierlbl,*Forcelbl,*ModifierTextlbl;
    UITextField *ModifierDesField,*PromptField;
    UITableView *ModifierGroupTable,*ModifierIndividualTable,*ToSelectTable;
    UIView *ModIndividualView;
    
    
    //modifier view
    
    //present modifier view
    
    UIView *modBackView,*modView;
    UIButton *ModifieritemsDropdownBtn,*SavemodBtn,*CancelModBtn,*DeleteItemNo;
    UITableView *ItemsListTable,*modifierItemsTable;
    UILabel *modTextlbl;
    NSMutableArray *itemsListArray;
    NSMutableArray *ModifierItemNosArray,*modifierNamesArray,*NamesArray,*Allmodifiers,*selectedModifiers,*SelectedNamesArray;
    
    
    //price levels view
    UIView *PriceLevelsBackView,*PriceLevelsView;
    UITableView *PriceLevelsTable;
    UILabel *PriceLevelTextlbl;
    UIButton *SavePriceLevelLbl,*CancelPricelevelbtn;
    
  
    
    NSMutableArray *ProductDepartmentsArray,*ItemNumbersArray,*ItemnameArray,*productDesArray,*CostArray,*priceyouchargeArray,*pricewithTaxArray,*InstockArray,*productVendorsArray,*taxvaluesArray;
   
    NSInteger selectedOrder;
    BOOL selectedorderinfo;
    
    //Ordering View
    UIView *OrderingInfoBackView;
    UIView *OrderingInfoView;
    UIButton *AddOpVendorBtn;
    UILabel *Addvendorlbl;
     UITableView *OrderingInfoTable,*OpVendorslistTable;
    UIButton *SaveOrderingInfoBtn,*CancelOrderingInfoBtn;
    NSMutableArray *OpVendorsArray;
    NSMutableArray *SelectedOpVendorsArray;
    UIButton *EditOrderingInfoBtn,*DeleteOrderingInfoBtn;
    UILabel *OrderingInfotextLbl;
    //Order Vendor Details View
    
    UIView *AddORVendorDetailsPopUp;
    UIScrollView *AddORVendordetailsView;
    UILabel *AddVendorDetailsLbl,*OrVendorlbl;
    UITextField *VendorField;
    UIButton *SaveORVendorDetailsBtn,*CancelORVendorDetailsBtn;
    NSString *VendorpartStr,*CostperStr,*CaseCostStr,*Numberincasestr;
    UILabel *Preferredlbl,*Truelbl,*falselbl;
    UIButton *trueRadioBtn,*falseRadioBtn;
    NSString *PreferredStr;
    NSMutableArray *VendorpartNosArray;
    
    NSMutableArray *VendorPartsArray,*CostpersArray,*CasecostsArray,*NumberincasesArray,*preferredsArray;
    
    
    //edit product view
    UITableView *editProductTable;
    UIButton *EditProductButton,*DeleteProductBtn,*DuplicateProductBtn,*InstanpoBtn;
    UIAlertView *deleteProductAlert;
    NSInteger SelectedProduct;
    
    UIView *EditproductPopUpView;
    UIScrollView *EditProductView;
    
    UIButton *ChangeDepartmentBtn,*ChangeSaveProductBtn,*ChangeCancelProductBtn,*Changetax1Btn,*Changetax2Btn,*Changetax3Btn,*ChangeBarTaxBtn,*ChangePriceWithTaxBtn,*ChangeAddpricingBtn;
    UITextView *ChangeDescriptionText;
    UITextField *ChangeItemNumberField,*ChangeItemNameField,*ChangeCostField,*ChangePriceyouChargeField,*ChangeInStockField;
    UILabel *ChangeDepartmentlbl,*ChangeItemNumberlbl,*ChangeItemNamelbl,*ChangeDescroptionlbl,*Changedatalbl,*Changepricinglbl,*Changetax1lbl,*Changetax2lbl,*Changetax3lbl,*Changebartaxlbl,*ChangeCostlbl,*ChangepriceyouChargelbl,*ChangepriceWithTaxlbl,*ChangeInStocklbl,*ChangeAddpricinglbl;
    UITableView *ChangeDepartmentsTable,*ChangeVendorsTable;
    
    UIButton *infoButtons,*infoButton2;
    double taxvalue;
    double Changetaxvalue;
    NSString *costStr,*TaxValueStr;
    NSString *tax1Str,*tax2Str,*tax3Str,*bartaxStr,*totalTaxStr;
    float ProductTotalTax;
    NSString *Changetax1Str,*Changetax2Str,*Changetax3Str,*ChangebartaxStr,*ChangetotalTaxStr;
    int ChangeProductTotalTax;
    NSString *ChangecostStr,*ChangeTaxValueStr;
    UIButton *ChangeinfoButtons,*ChangeinfoButton2;
    
    
    //Duplicate product view
    
    UIView *DuplicateproductPopUpView;
    UIScrollView *DuplicateProductView;
    
    UIButton *DuplicateDepartmentBtn,*DuplicateSaveProductBtn,*DuplicateCancelProductBtn,*Duplicatetax1Btn,*Duplicatetax2Btn,*Duplicatetax3Btn,*DuplicateBarTaxBtn,*DuplicatePriceWithTaxBtn,*DuplicateAddpricingBtn;
    UITextView *DuplicateDescriptionText;
    UITextField *DuplicateItemNumberField,*DuplicateItemNameField,*DuplicateCostField,*DuplicatePriceyouChargeField,*DuplicateInStockField;
    UILabel *DuplicateDepartmentlbl,*DuplicateItemNumberlbl,*DuplicateItemNamelbl,*DuplicateDescroptionlbl,*Duplicatedatalbl,*Duplicatepricinglbl,*Duplicatetax1lbl,*Duplicatetax2lbl,*Duplicatetax3lbl,*Duplicatebartaxlbl,*DuplicateCostlbl,*DuplicatepriceyouChargelbl,*DuplicatepriceWithTaxlbl,*DuplicateInStocklbl,*DuplicateAddpricinglbl;
    UITableView *DuplicateDepartmentsTable,*DuplicateVendorsTable;
    
    UIButton *DuplicateinfoButtons,*DuplicateinfoButton2;
    //Instant po view
    UIView *InstantPoPOPupView,*InstantPOView;
    UILabel *Instantpolbl;
    UITextField *InstantpoField;
    UIButton *SaveInstantPoBtn,*CancelInstantpoBtn;
    
    
    NSURLConnection *CategoryConnection,*VendorConnection,*SkuConnection,*ModifierConnection,*OrderinfInfoConnection;
    NSMutableData *CatresponseData,*vendorResponseData,*SkuResponseData,*ModifierResponseData,*OrderinfInfoResponseData;
    
    
    //product serach bar views
    
    UIView *EditProductBackView;
    
    UILabel *Catlbl,*Deptlbl,*Searchlbl,*displaylbl;
    UIButton *Gobtn,*ResultspersetBtn,*CatField,*DeptField;
    UITextField *SearchField;
    UITableView *DisplaySettable;
    
    
    //product category view
    UIView *Pcategorypopup;
    UITableView *PCategorysTable;
    //Product department view
    UIView *Pdeaprtmentpopup;
    UITableView *PdepartmentsTable;
    UITableView *SearchlistTable;
    
    NSMutableArray *SearchDataArray;
    NSMutableArray *pastDataArray;
    
    NSString *SelectedResultsForSet;
    
//Hiestory View
    UIView *HistoryPopupView,*HistoryView;
    UILabel *Historytextlbl;
    UIButton *saveHistoryBtn,*CancelHistoryBtn;
    
    UITableView *SalesHistoryTable;
    
    NSMutableArray *itemIDArray,*itemNameArray,*discountArray,*taxArray,*yourCostArray,*avgArray,*quantityArray,*dateArray;
    
     UILabel *sationLbl,*Timelbl,*EmpIdlbl;
    UIButton *logoBtn;
    
    
    NSMutableArray *SnosArray;
    NSMutableDictionary *dataDict;
    
//taxes
    NSString *tax1Name,*tax2Name,*tax3Name,*tax1Rate,*tax2Rate,*tax3Rate;

    IBOutlet ProductCell *productCell;
    IBOutlet CategoryCell *categoryCell;
    IBOutlet DepartmentCell *departmentCell;
    IBOutlet VendorCell *vendorCell;
    IBOutlet InventorySalesCell *inventorySalesCell;
    IBOutlet OrderingInfoCell *orderingInfoCell;
    IBOutlet ModifierItemCell *modifierItemCell;
    UIImage *btnGreyImg;
  
    
}

- (IBAction)product_editButtonClicked:(id)sender;
- (IBAction)product_viewButtonClicked:(id)sender;
- (IBAction)product_duplicateButtonClicked:(id)sender;
- (IBAction)product_deleteButtonClicked:(id)sender;

- (IBAction)category_editButtonClicked:(id)sender;
- (IBAction)category_deleteButtonClicked:(id)sender;

- (IBAction)Department_editButtonClicked:(id)sender;

- (IBAction)Department_duplicateButtonClicked:(id)sender;
- (IBAction)Department_deleteButtonClicked:(id)sender;
- (IBAction)vendor_editButtonClicked:(id)sender;
- (IBAction)vendor_deleteButtonClicked:(id)sender;

- (IBAction)orderingInfo_editButtonClicked:(id)sender;
- (IBAction)orderingInfo_deleteButtonClicked:(id)sender;
- (IBAction)modifierItem_deleteButtonClicked:(id)sender;

-(void)ProductpaginationMetod;
-(void)releaseViews;

@end
